package weeek12.topic03;

import lombok.SneakyThrows;
import org.redisson.Redisson;
import org.redisson.api.*;
import org.redisson.config.Config;

public class RedissionListAndAtomicTest {

    @SneakyThrows
    public static void main(String[] args) {
        Config config = new Config();
        config.useSingleServer().setAddress("redis://127.0.0.1:6379");

        final RedissonClient client = Redisson.create(config);
        //list
        RList<Object> rList = client.getList("rlist1");
        System.out.println(rList);

            for (int i = 0; i < 15; i++) {
                rList.add( "rList:"+i);
            }

        System.out.println(rList);
        //Atomic
        RAtomicLong atomLong = client.getAtomicLong("atomLong");
        System.out.println("first get:"+atomLong.get());
        atomLong.incrementAndGet();
        atomLong.incrementAndGet();
        atomLong.incrementAndGet();
        System.out.println("second get:"+atomLong.get());

    }

    // 可参阅：https://www.jianshu.com/p/47fd7f86c848

}
